﻿using System;
using Modalities = Eflong.MonitoringLib.MonitoringUnit.MonitoringUnitModality.Modalities;
using States = Eflong.MonitoringLib.MonitoringUnit.MonitoringUnitState.States;
using Types = Eflong.MonitoringLib.MonitoringUnit.MonitoringUnitType.Types;

namespace Eflong.Monitor
{
    /// <summary>
    /// 报警记录表结构
    /// </summary>
    public class ExcessRecord
    {
        public Int32 AutoId;

        /// <summary>
        /// 报警开始/解除时刻
        /// </summary>
        public DateTime Time;

        /// <summary>
        /// 传感器状态
        /// </summary>
        public States State;

        /// <summary>
        /// 传感器报警、解除值
        /// </summary>
        public float Value;

        /// <summary>
        ///  矿的ID
        /// </summary>
        public int CoalMineId;

        /// <summary>
        /// 矿名
        /// </summary>
        public string CoalMineName;

        /// <summary>
        /// 传感器的 ID
        /// </summary>
        public string MonUnitId;

        /// <summary>
        /// 名称及地点信息
        /// </summary>
        public string MonUnitName;

        /// <summary>
        /// 传感器类型名
        /// </summary>
        public string MonUnitType;

        /// <summary>
        /// 传感器单位
        /// </summary>
        public string MonUnitUnit;

        /// <summary>
        /// 传感器分类
        /// </summary>
        public Modalities Modality;

        public Types Type;

        public string[ ] ValueDecs = new string[ 3 ] { "" , "" , "" };

        /// <summary>
        /// 报警原因
        /// </summary>
        public string Causation;

        /// <summary>
        /// 采取措施
        /// </summary>
        public string AdoptMeasure;

        //
        public DateTime AdoptMeasureTime;

        //
        /// <summary>
        /// 原因分析
        /// </summary>
        public string AnalyseInfo;

        public ExcessRecord( )
        {
            CoalMineId = 0;
        }

        public bool IsAlert( )
        {
            if ( ( State >= States.UnderLowerLimit ) && ( State <= States.OverTiming ) )
            {
                return true;
            };
            if ( ( State == States.State1 ) || ( State == States.State2 ) )
            {
                return true;
            }
            return false;
        }

        public bool IsFault( )
        {
            return ( State >= States.UnknownState );
        }
    }
}